//
//  MacroDefine.h
//  wozhua
//
//  常用的宏定义
//
//  Created by 王洋 on 14-9-28.
//  Copyright (c) 2014年 王洋. All rights reserved.
//

#define kScreenWidth  [UIScreen mainScreen].bounds.size.width
#define kScreenHeight [UIScreen mainScreen].bounds.size.height

#define TopHeight  [[UIApplication sharedApplication] statusBarFrame].size.height + self.navigationController.navigationBar.frame.size.height
#define TabBarHeight  self.navigationController.tabBarController.tabBar.frame.size.height
#define HeadHeight  64
#define Header_height  kScreenWidth/2
#define ShopHeaderHeight  150
#define kSeparatorHeight  0.49

#define APP_DELEGATE ((AppDelegate *)[UIApplication sharedApplication].delegate)
#define UserInfo [UserInfoManager sharedManager]
#define  StringWith(param) [NSString stringWithFormat:@"%@",param] //转换为字符串

//当前对象的内存地址对应的key 用于back时取消网络请求
#define kSelfMemoryAddressKey @"kSelfMemoryAddressKey"

//适配ios10控制台打印数据不全的bug
#ifdef DEBUG
#define DELog(FORMAT, ...) fprintf(stderr, "%s:%d\t%s\n", [[[NSString stringWithUTF8String: __FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat: FORMAT, ## __VA_ARGS__] UTF8String]);
#else
#define DELog(FORMAT, ...) nil
#endif


#define SuppressPerformSelectorLeakWarning(Stuff) \
do { \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
Stuff; \
_Pragma("clang diagnostic pop") \
} while (0)

#define WEAKSELF typeof(self) __weak weakSelf = self; //weak self for block
#define STRONGSELF typeof(weakSelf) __strong strongSelf = weakSelf; //strong self for block

#define kImagePlaceholder [UIImage imageNamed:@"picture_placeholder" classForBundle:[self class]]

#define kIsAfterIOS11 ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 11.0f)
#define kIsAfterIOS9 ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 9.0f)
#define kIsAfterIOS8 ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 8.0f)
#define kIsBeforeIOS8 ([[[UIDevice currentDevice] systemVersion] doubleValue] < 8.0f)
#define kIsAfterIOS7 ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 7.0f)
#define kIsSmallIphone ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)
#define kIsBigIphone ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO)
#define kIsIphoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO)

#define AdjustsScrollViewInsetNever(controller,view) if(@available(iOS 11.0, *)) {view.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;} else if([controller isKindOfClass:[UIViewController class]]) {controller.automaticallyAdjustsScrollViewInsets = false;}

#define TICK NSDate *funcStartTime = [NSDate date]
#define TOCK NSLog(@"Time: %f", -[funcStartTime timeIntervalSinceNow])


